﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 

class NewApp extends BaseApp
{

    var $type = 'new';
	
	
    function index()
    {
        if(!isset($_GET['catid']))
		{
		$_GET['catid'] = '';
		}	
        if(!isset($_GET['condition']))
		{
		$_GET['condition'] = '';
		}
		$condition = $_GET['condition'];						
		$catid = intval($_GET['catid']);	
        if(!isset($_GET['word']))
		{
		$_GET['word'] = '';
		}					
        if(!isset($_POST['word']))
		{
		$_POST['word'] = '';
		}
		
        if(!isset($_GET['v']))
		{
		$_GET['v'] = '';
		}
		if($_GET['word'])
		{
	    $word = $_GET['word'];		
		}
		if($_POST['word'])
		{
	    $word = $_POST['word'];		
		}		

		$word_array = explode(' ',$word);
		
		foreach($word_array as $key => $value)
		{
			if(!$value)
			{
             unset($word_array[$key]);
		    }  
		}
		 
        $order = '';
		$v = $_GET['v'];
		if($v == 'timeasc')
		{
        $order = 'A.add_time asc';
		}
		else if($v == 'timedesc')
		{
        $order = 'A.add_time desc';		
		}
		else if($v == 'showyes')
		{
        $order = 'A.is_show desc';		
		}
		else if($v == 'showno')
		{
        $order = 'A.is_show asc';		
		}
		else if($v == 'topyes')
		{
        $order = 'A.is_top desc';		
		}
		else if($v == 'topno')
		{
        $order = 'A.is_top asc';		
		}
		else if($v == 'recyes')
		{
        $order = 'A.is_recommend desc';		
		}
		else if($v == 'recno')
		{
        $order = 'A.is_recommend asc';		
		}
		else if($v == 'indexyes')
		{
        $order = 'A.is_index desc';		
		}
		else if($v == 'indexno')
		{
        $order = 'A.is_index asc';		
		}
				
        $temp_condition = $condition;
        if($condition == 'showyes')
		{
        $condition = 'A.is_show=1';		
		}
		else if($condition == 'showno')
		{
        $condition = 'A.is_show=0';		
		}
		else if($condition == 'topyes')
		{
        $condition = 'A.is_top=1';		
		}
		else if($condition == 'topno')
		{
        $condition = 'A.is_top=0';		
		}
		else if($condition == 'recyes')
		{
        $condition = 'A.is_recommend=1';		
		}
		else if($condition == 'recno')
		{
        $condition = 'A.is_recommend=0';		
		}
		else if($condition == 'indexyes')
		{
        $condition = 'A.is_index=1';		
		}
		else if($condition == 'indexno')
		{
        $condition = 'A.is_index=0';		
		}		
				
	
	
		$TB_new = &$this->_model('new');
				
		$data = $TB_new->show($order,$v,$word_array,'2',$this->type,$catid,$condition,$word,$temp_condition);	

			
        $this->assign('lw_data', $data['data']);		
		$this->assign('lw_page', $data['page']);	
		
		
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
		if(!is_array($categorydata))
		{
		 $categorydata = (array)$categorydata;
		}		
		$categorylist = array();
		foreach($categorydata as $value)
		{
		    $categorylist[$value['cat_id']] = $value['cat_name'];
		}		
		
        $this->assign('categorylist', $categorylist);							
        $this->assign('categorydata', $categorydata);		    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		$this->assign('word', $word);
		$this->assign('v', $v);
		$this->assign('condition', $temp_condition);		
		$this->assign('catid', $catid);
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('new_list.view.html');
    }

    function add()
    {
		
	
		$TB_new = &$this->_model('new'); 
		
		$id_array = $TB_new->select_id($GLOBALS['SCup']->SCup_user_msg['data']['user_name']);		
		foreach($id_array as $value)
		{ 
		   if($value['id']&&file_exists(ROOT_PATH . '/' . UPFILE_PATH . '/' . $this->type . '/' . $value['id'] . '/'))
		   {
		     del_file(ROOT_PATH . '/' . UPFILE_PATH . '/' . $this->type . '/' . $value['id'] . '/');
		   }	
		}
				
		$TB_new->delet_id($GLOBALS['SCup']->SCup_user_msg['data']['user_name']);	

		$data_id = $TB_new->insert_id($GLOBALS['SCup']->SCup_user_msg['data']['user_name']);
		
        $this->assign('id', $data_id);	
				
        $this->assign('keyworddata', del_empty_var(explode('+', AWAY_USE_KEYWORD)));	
        $this->assign('zhandian', del_empty_var(explode('+', AWAY_USE_ZHANDIAN)));		
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
		   
        $this->assign('categorydata', $categorydata);		
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('new_add.view.html');
    }
	
    function kindeditor()
    {
	 if(!isset($_GET['w']))
	 {
	 $_GET['w']='';
	 }
    $w = intval($_GET['w']);
    include(ROOT_PATH."/data/ewebeditor/ewebeditor.lib.php");		
	
	$kindeditor = new Ewebeditor(array('imageUploadCgi'=>SITE_URL.'/admin/index.php?app=new&act=kindeditorupfile&w='.$w));
	$kindeditor->show();
	
    }
	
    function kindeditorupfile()
    {
	 if(!isset($_GET['w']))
	 {
	 $_GET['w']='';
	 }	
    $w = intval($_GET['w']);
    include(ROOT_PATH."/data/ewebeditor/ewebeditor.lib.php");	
	
	$kindeditor = new Ewebeditor(array('imageUploadCgi'=>SITE_URL.'/admin/index.php?app=new&act=kindeditorupfile&w='.$w));
	$kindeditor->upfile('new/'.$w);
	
    }
	
	

    function cagryadd()
    {
	
		$GLOBALS['Lang']->_get_lang('new');
		
	    $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		$catgydata = $category->show($this->type);
		
		$catgystr = $category->html_format_category($catgydata,0);	

        $this->assign('catgystr', $catgystr);	
		
        $this->assign('category_value', $this->type);
			    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('cagryadd.view.html');
    }
	
    function editcatgy()
    {
	
	    $GLOBALS['Lang']->_get_lang('new');
		$id= intval($_GET['id']);
		
	    $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		$catgydata = $category->show($this->type);
		
		$data = $category->oneshow($id);
		
		$catgystr = $category->html_format_category($catgydata,$data['parent_id'],0,0,$id);	
        $this->assign('data', $data);

        $this->assign('catgystr', $catgystr);
		
        $this->assign('category_value', $this->type);
			    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('cagryedit.view.html');
    }
	
    function cagrylist()
    {
		$GLOBALS['Lang']->_get_lang('new');
	    $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		$catgydata = $category->show($this->type);
		$catgydata = $category->get_list_category($catgydata);

		
        $this->assign('catgydata', $catgydata);				

        $this->assign('category_value', $this->type);
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('cagrylist.view.html');
    }

    function cyaddpost()
    {

	     $data = $_POST['data'];
         
		 $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		 $category->post($data);
		 
		 $category->write_cache($this->type);	
		 	 		 
		 $this->cagrylist();

    }


    function cyeditpost()
    {

	     $id = $_POST['id'];

	     $data = $_POST['data'];
         
		 $category = & $GLOBALS['SCup']->_get_category();
		 		 		
		 $category->editaction($id,$data);

		 $category->write_cache($this->type);	
		 	 		 
		 $this->cagrylist();

    }

	
    function addpost()
    {

	     $data = $_POST['data'];
		 $id = $_POST['id'];
         if(!isset($data['cat_id'])||empty($data['cat_id']))
		{
		 $notice = &get_message(array('msg'=>"所属栏目不能为空!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		 
		 }
		 		 
		 $data['user_id'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
		 $data['user_name'] = $GLOBALS['SCup']->SCup_user_msg['data']['user_name'];	 
		/* $data['config'] = serialize(array('titlecolor'=>$data['titlecolor'],'fonttype'=>$data['fonttype']));*/
         $data['config'] = serialize(array('titlecolor'=>'','fonttype'=>''));
		 if(empty($data['yz']))
		 {
		    $data['yz']='0';
		 }  
		 if(empty($data['top']))
		 {
		    $data['top']='0';
		 }  
		 if(empty($data['levels']))
		 {
		    $data['levels']='0';
		 }  
		 if(empty($data['special']))
		 {
		    $data['special']='0';
		 }  		 
		          

		 $TB_new = &$this->_model('new'); 
		 		 		
		 $TB_new->post($id,$data);

/*		$view = &get_view();
	    $view->html($id,SITE_URL ."/?app=new&act=show&id=".$id."&langid=".trim($GLOBALS['Lang']->_lang_tp),'new');
*/		
		$notice = &get_message(array('msg'=>"提交成功!",'url'=>'','title'=>'Notice'));
		$notice ->display();		 


    }

    function upfile()
    {

	 if(!isset($_POST["action"]))
	 {
	 $_POST["action"]='';
	 }
	 if(!isset($_GET['id']))
	 {
	 $_GET['id']='';
	 }
	 if(!isset($_GET["edit"]))
	 {
	 $_GET["edit"]='';
	 }	 
	 if(!isset($_GET["picurl"]))
	 {
	 $_GET["picurl"]='';
	 }	 
			
		$action = $_POST["action"];
		
		$id = intval($_GET['id']);
		
		$edit = $_GET["edit"];
		$picurl = $_GET["picurl"];
		if($edit)
		{
        $this->assign('edit', $edit);		
		}
        if($picurl)
		{
        $this->assign('picurl', $picurl);
		}

						
		if($action == 'post')
		{
	 				
	 					if(!$_FILES['postfile1']['tmp_name']){
	 						$id || $id = intval($_POST['id']);	
							echo '<script> alert("请选择上传的图片");</script>';
						}else{
					        if(!isset($_POST["edit"]))
					        {
					         $_POST["edit"]='';
					        }	 
					        if(!isset($_POST["picurl"]))
					        {
					         $_POST["picurl"]='';
					        }
					       if(!isset($_POST['id']))
					       {
					        $_POST['id']='';
					        }	 
					 			
						       $edit = $_POST["edit"];
						       $picurl = $_POST["picurl"];
						 	   $id || $id = intval($_POST['id']);		
				
						       include(ROOT_PATH.'/lib/upfile.lib.php');	  
					           $upfile = new Upfile('new/'.$id); 	  
					           $updata = $upfile->_batch_upfile('new');		 
						 		 
						       $newfile = $updata[1]['path'];
						       
							   if($edit=='editp' && $picurl)
							   {
							   
							          $TB_new = &$this->_model('new');			    		 		 		
						              $TB_new->editpicurl($id,array('picurl'=>$newfile));
									  
						              $pic_dir= ROOT_PATH . '/' . UPFILE_PATH . '/' . $picurl;
			                          if(!is_dir($pic_dir)&&file_exists($pic_dir))
		                              {
		                               del_file($pic_dir);	
		                               }										  
			   
							   }
							   
							    if($edit=='edit' && $picurl)
						       {
						              $pic_dir= ROOT_PATH . '/' . UPFILE_PATH . '/' . $picurl;
			                          if(!is_dir($pic_dir)&&file_exists($pic_dir))
		                              {
		                               del_file($pic_dir);	
		                               }										  		 
						       }
						 	   
							
						
						      $pic_url = SITE_URL . '/' . UPFILE_PATH . '/' .$newfile;
				
					    echo "<A HREF='?app=new&act=upfile&edit=edit&picurl=$newfile&id=$id'>修改图片</A>&nbsp;&nbsp;<a href='javascript:' style='color:red;' onClick=\"javascript:window.open('?app=new&act=cutimg&nextpic=1&width=400&height=325&srcimg={$pic_url}','','width=580,height=530');\">[裁剪图片]</a>";
					     
						$jsfun="upfile";
					    echo "<script>
								if(self==top){
									window.opener.$jsfun('$newfile','uppic');
									window.self.close();
								}else{
									window.parent.$jsfun('$newfile','uppic');
								}
						     </script>";
								
					    exit;
						
				}
		}

        $this->assign('id', $id);
	    $this->assign('app', $this->type);		    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('edit',$edit);
        $this->assign('picurl',$picurl);	

        $this->assign('alldirpicurl',ROOT_PATH.'/'.UPFILE_PATH.'/'.$picurl);
					
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('upfile.view.html');
    }

    function cutimg()
    {
	 if(!isset($_POST['action']))
	 {
	 $_POST['action'] = '';
	 }
     $action = $_POST['action'];
	 
    if($action=="cutimg")
	{
     $uploadfile = $_POST['uploadfile'];	
     $x = $_POST['x'];
     $y = $_POST['y'];	 
     $w = $_POST['w'];	 
     $h = $_POST['h'];	 
     $scale = $_POST['scale'];
     $rw = $_POST['rw'];	 
     $rh = $_POST['rh'];	 

	 if(!isset($_GET['post']))
	 {
	    $_GET['post'] = '';
	 }
	 $post = $_GET['post'];

	 
	$NewPic=str_replace(SITE_URL.'/'.UPFILE_PATH.'/',"",$uploadfile);
	$NewPic=ROOT_PATH.'/'.UPFILE_PATH.'/'.$NewPic;
	$pathinfo = pathinfo(basename($NewPic));
//	$NewPic = str_replace("_old",'',$NewPic);
		
	if(!getimagesize($NewPic)){
		die("图片有误!!");
	}
    @include_once(ROOT_PATH ."/lib/image.lib.php");
	

	 if($post=='gai')
	 {	
	    $oldpic = str_replace($pathinfo['filename'],$pathinfo['filename']."_old",$NewPic);	 
		if(!strstr($oldpic, '_old_old')&&!is_file($oldpic))
		{
	     copy($NewPic,$oldpic);	
		} 
	    $oldpic = $NewPic;	
	 }
	 else
	 {
	  $oldpic = str_replace($pathinfo['filename'],$pathinfo['filename']."_old",$NewPic);	 
	  copy($NewPic,$oldpic);	 
	 }	
    if($post=='gai')
	{
	$oldpic1 = str_replace("_old",'',$NewPic);	
	Image::cutimg($NewPic,$oldpic1,$x,$y,$rw,$rh,$w,$h,$scale);		
	}
	else
	{
	Image::cutimg($NewPic,$NewPic,$x,$y,$rw,$rh,$w,$h,$scale);	
	}

	
	$oldpic = str_replace(ROOT_PATH.'/'.UPFILE_PATH.'/',"",$oldpic);
	//$oldpic	= SITE_URL.'/'.UPFILE_PATH.'/'.$oldpic ;
	$pic1="$uploadfile";
	$pic1 = str_replace("_old",'',$pic1);		
	echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
	die("剪裁成功,你可以点击查看截图效果:<br><A HREF='$pic1' target=_blank>样式</A><br> <a href='?app=new&act=cutimg&nextpic=1&width=400&height=325&post=gai&srcimg={$pic1}'>从新剪裁</a><br> <a href='javascript:window.self.close()'>点击关闭</a>");
	exit;
    }
		$height= $_GET['height'];		
		$width= $_GET['width'];	
		$nextpic= $_GET['nextpic'];			
		$srcimg= $_GET['srcimg'];
		$tempsrcimg = $srcimg;
	   if(!isset($_GET['post']))
	   {
	    $_GET['post'] = '';
	   }
	   $post = $_GET['post'];
	   if($post=='gai')
	   {
	   	$srcimg=str_replace(SITE_URL.'/'.UPFILE_PATH.'/',"",$srcimg);
		$srcimg = str_replace("_old",'',$srcimg);			 
	   	$pathinfo = pathinfo(basename($srcimg));
	
		$srcimg = str_replace($pathinfo['filename'],$pathinfo['filename']."_old",$srcimg);
		if(is_file(ROOT_PATH.'/'.UPFILE_PATH.'/'.$srcimg))
		{
		$srcimg = SITE_URL.'/'.UPFILE_PATH.'/'.$srcimg;		
		}
		else
		{
		$srcimg = $tempsrcimg;	
		}

	   }
        $this->assign('tempsrcimg', $tempsrcimg);		   	
        $this->assign('height', $height);					
        $this->assign('width', $width);
        $this->assign('nextpic', $nextpic);		
        $this->assign('srcimg', $srcimg);		
        $this->assign('post', $post);
						
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('cutimg.view.html');     

    }



    function edit()
    {
		$id= intval($_GET['id']);
		
		$TB_new = &$this->_model('new');
				
		$data = $TB_new->oneshow($id);	
		
		$data['content'] = str_replace("'", "&rsquo;", $data['content']);		
			
        $this->assign('keyworddata', del_empty_var(explode('+', AWAY_USE_KEYWORD)));	
        $this->assign('zhandian', del_empty_var(explode('+', AWAY_USE_ZHANDIAN)));
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
		
        $this->assign('categorydata', $categorydata);

        $this->assign('data', $data);

        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('new_edit.view.html');     

    }

    function editpost()
    {
		$id= intval($_POST['id']);
		
		$data = $_POST['data'];
         if(!isset($data['cat_id'])||empty($data['cat_id']))
		{
		 $notice = &get_message(array('msg'=>"所属栏目不能为空!",'url'=>'','title'=>'Notice'));
		 $notice ->display();		 
		 }
		
		
		
		 $data['user_id'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
		 $data['user_name'] = $GLOBALS['SCup']->SCup_user_msg['data']['user_name'];	 
/*		 $data['config'] = serialize(array('titlecolor'=>$data['titlecolor'],'fonttype'=>$data['fonttype']));*/
         $data['config'] = serialize(array('titlecolor'=>'','fonttype'=>''));
		 if(empty($data['yz']))
		 {
		    $data['yz']='0';
		 }  
		 if(empty($data['top']))
		 {
		    $data['top']='0';
		 }  
		 if(empty($data['levels']))
		 {
		    $data['levels']='0';
		 }  
		 if(empty($data['special']))
		 {
		    $data['special']='0';
		 }  		 
		  
 		$TB_new = &$this->_model('new');  
				
		$TB_new->editaction($id,$data);
/*		$view = &get_view();
	    $view->html($id,SITE_URL ."/?app=new&act=show&id=".$id."&langid=".trim($GLOBALS['Lang']->_lang_tp),'new');	
*/		
		 $notice = &get_message(array('msg'=>"提交成功!",'url'=>'','title'=>'Notice'));
		 $notice ->display();	 	      

    }
	
	
	
    function lcsort()
    {
		$id= intval($_GET['id']);
		$v= intval($_GET['v']);		
        unset($data);
		$data[sort_order] = $v;
		
	    $category = & $GLOBALS['SCup']->_get_category();		 		 		
		$category->editsort($id,$data);
		
		$category->write_cache($this->type);	
					      
		$this->cagrylist();   
    }	
		
    function delcatgy()
    {
		$id= intval($_GET['id']);		

	    $category = & $GLOBALS['SCup']->_get_category();		 		 		
		$category->del($id);
		
		$category->write_cache($this->type);
				      
		$this->cagrylist();   
    }	
    function del()
    {
	    if(!isset($_POST['jobs'])){$_POST['jobs']=0;}	
		$jobs = $_POST['jobs'];
        if($jobs ==='del')
		 {
		    if(!isset($_POST['checkdata'])){$_POST['checkdata']=array();}
             if(empty($_POST['checkdata']))
			 {
		    $notice = &get_message(array('msg'=>"请至少选择一个删除项目！",'url'=>'?app='.$this->type.'&act=index','title'=>'Notice'));
		    $notice ->display();				 
			 }
		    $checkdata = $_POST['checkdata'];		

			$str1=$str2='';
			
			foreach($checkdata as $key => $value)
			{
			  $str1.="id='".$value."'  or ";
			  $str2.="con_id='".$value."'  or ";
			          if($value&&file_exists(ROOT_PATH . '/' . UPFILE_PATH . '/' . $this->type . '/' . $value. '/'))
		              {
		               del_file(ROOT_PATH . '/' . UPFILE_PATH . '/' . $this->type . '/' . $value. '/');	
		              }				  			  			  
			}			
			$str1 = substr($str1, 0,-3);
			$str2 = substr($str2, 0,-3);			
			$db = & get_db();	
			$db->query("DELETE FROM ".DB_PREFIX."huiying WHERE table_id=1 and (".$str2. ") ");						
			$db->query("DELETE FROM ".DB_PREFIX."content WHERE "	.$str1. " ");
			$db->query("DELETE FROM ".DB_PREFIX."content_1 WHERE "	.$str2. " ");
					
		    $view = &get_view();
			foreach($checkdata as $key => $value)
			{
	          $view->delhtml($value,'new');			  		  
			}				
		    $notice = &get_message(array('msg'=>"删除成功！",'url'=>'?app=new&act=index','title'=>'Notice'));
		    $notice ->display();				 
	         
		}	
		$id= intval($_GET['id']);
		$TB_huiying = &$this->_model('huiying');
		$data = $TB_huiying->del_content_id('1',$id);				 		 		 		
/*		$data = $TB_huiying->oneshow('1',$id);		
		if(isset($data['id']))
		{
		 $notice = &get_message(array('msg'=>"请先删除该产品的评论，才能进行删除操作！",'url'=>'','title'=>'Notice'));
		 $notice ->display();			
		}	*/		

		if($id&&file_exists(ROOT_PATH . '/' . UPFILE_PATH . '/' . $this->type . '/' . $id. '/'))
		{
		 del_file(ROOT_PATH . '/' . UPFILE_PATH . '/' . $this->type . '/' . $id. '/');	
		}				
	
		$TB_new = &$this->_model('new');
		$TB_new->del($id);
		$view = &get_view();
	    $view->delhtml($id,'new');						  
        $this->index();    
    }

    function batch()
    {  
	    if(!isset($_POST['jobs'])){$_POST['jobs']=0;}

	    if(!isset($_GET['selcetid'])){$_GET['selcetid']=0;}	
	    if(!isset($_POST['checkdata'])){$_POST['checkdata']=array();}
        if(empty($_POST['checkdata']))
		{
		    $notice = &get_message(array('msg'=>"请至少选择一个项目！",'url'=>'?app='.$this->type.'&act=index','title'=>'Notice'));
		    $notice ->display();				 
		}
		$checkdata = $_POST['checkdata'];		

		$str1=$str2='';
		foreach($checkdata as $key => $value)
		{
			  $str1.="id='".$value."'  or ";
			  $str2.="con_id='".$value."'  or ";

		}			
		$str1 = substr($str1, 0,-3);
		$str2 = substr($str2, 0,-3);		
		$db = & get_db();						 						
		$jobs = $_POST['jobs'];
		
        if($jobs=='html')
		{
		
		    $view = &get_view();
		    foreach($checkdata as $key => $value)
		    {
	        $view->html($value,SITE_URL ."/?app={$this->type}&act=show&id=$value",$this->type);	
		    }
		
		$notice = &get_message(array('msg'=>"操作成功！",'url'=>'?app='.$this->type.'&act=index','title'=>'Notice'));
		$notice ->display();		 
		}		
        if($jobs=='move')
		{
		$selcetid = intval($_GET['selcetid']);
		$db->query("UPDATE ".DB_PREFIX."content SET cat_id='{$selcetid}' WHERE ".$str1." ");
		$db->query("UPDATE ".DB_PREFIX."content_1 SET cat_id='{$selcetid}' WHERE ".$str2." ");		
		$notice = &get_message(array('msg'=>"操作成功！",'url'=>'?app='.$this->type.'&act=index','title'=>'Notice'));
		$notice ->display();		 
		}
        if($jobs)
		 {            
			$jobdata = del_empty_var(explode(':', $jobs));	
			$filed_key = $jobdata[0];
			$filed_value = $jobdata[1];		 
			$db->query("UPDATE ".DB_PREFIX."content SET {$filed_key}='{$filed_value}' WHERE ".$str1." ");
		    $notice = &get_message(array('msg'=>"操作成功！",'url'=>'?app='.$this->type.'&act=index','title'=>'Notice'));
		    $notice ->display();	 
		}

    }		
	
				
    function huilist($id=0)
    {
	     if(!$id)
		 {
		 $id = intval($_GET['id']);	
		 }	 
		 $TB_huiying = &$this->_model('huiying');		 		 		 		
		 $data = $TB_huiying->show('1',$id,'new');
        $this->assign('lw_data', $data['data']);		
		$this->assign('lw_page', $data['page']);		 
		 	
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
        $this->assign('appname', $this->type);		
        $this->assign('site_url',SITE_URL);
        $this->assign('topid',$id);		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('hui_list.view.html');
    }
    function huidel()
    {
		$id= intval($_GET['id']);	
		$topid= intval($_GET['topid']);			
			
		$TB_huiying = &$this->_model('huiying');
		
		$TB_huiying->del($id);

        $this->huilist($topid);   
    }
}





?>